package com.ruoyi.backend.service.Impl;

import com.ruoyi.backend.dto.InverseInfoDTO;
import com.ruoyi.backend.mapper.SatelliteMapper;
import com.ruoyi.backend.mapper.UavMapper;
import com.ruoyi.backend.pojo.Satellite;
import com.ruoyi.backend.pojo.Uav;
import com.ruoyi.backend.service.InversionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InversionServiceImpl implements InversionService {

    @Autowired
    UavMapper uavMapper;

    @Autowired
    SatelliteMapper satelliteMapper;


    @Override
    public void inverse(InverseInfoDTO inverseInfoDTO) {

        String[] split = inverseInfoDTO.getEcologicalIdList().split(",");

        for (String ecoParameterId : split) {
            switch (ecoParameterId)
                {
                    case "1":
                        //调用python脚本
                        break;
                    case "2":
                        //调用python脚本
                        break;
                    case "3":
                        //调用python脚本
                        break;
                    case "4":
                        //调用python脚本
                        break;
                    case "5":
                        //调用python脚本
                        break;
                    case "6":
                }
        }
    }

    /**
     * 在数据库表中查找符合要求的数据：无人机数据
     * 查找到就返回对应的文件存储地址，否则返回null
     */

    public Uav findUavData(InverseInfoDTO inverseInfoDTO)
    {
        Uav uavData = uavMapper.searchUavData(inverseInfoDTO.getMineId(), inverseInfoDTO.getDataTime(), inverseInfoDTO.getSpatialCoverage());
        if (uavData == null)
            throw new RuntimeException("未找到匹配的UAV数据");
        return uavData;
    }

    /**
     * 在数据库表中查找符合要求数据：卫星数据
     * 查找到就返回对应的文件存储地址，否则返回null
     */
    public Satellite findSatelliteData(InverseInfoDTO inverseInfoDTO)
    {
        Satellite satelliteData = satelliteMapper.searchSatelliteData(inverseInfoDTO.getMineId(), inverseInfoDTO.getDataTime(), inverseInfoDTO.getSpatialCoverage());
        if (satelliteData == null)
            throw new RuntimeException("未找到匹配的卫星数据");
        return satelliteData;
    }


}
